package com.gxy.learn.design.model.behaviour.state;

/**
 * @description: 环境角色类
 * @author: gaoxueyong
 * @Date: 2022/11/8 17:05
 */
public class Context {
    //    对象状态
    public final static OpeningState OPENING_STATE = new OpeningState();
    public final static ClosingState CLOSING_STATE = new ClosingState();
    public final static RunningState RUNNING_STATE = new RunningState();
    public final static StopingState STOPING_STATE = new StopingState();

    private LiftState liftState;

    public void setLiftState(LiftState liftState) {
        this.liftState = liftState;
//        设置当前对象的Context对象
        this.liftState.setContext(this);
    }

    /**
     * 打开电梯门
     *
     * @return void
     * @Author gaoxueyong
     * @Date 5:12 下午 2022/11/8
     * @Param []
     **/
    public void open() {
        this.liftState.open();
    }

    /**
     * 电梯关门
     *
     * @return void
     * @Author gaoxueyong
     * @Date 5:12 下午 2022/11/8
     * @Param []
     **/
    public void close() {
        this.liftState.close();
    }

    /**
     * 电梯运行中
     *
     * @return void
     * @Author gaoxueyong
     * @Date 5:12 下午 2022/11/8
     * @Param []
     **/
    public void run() {
        this.liftState.run();
    }

    /**
     * 电梯停止
     *
     * @return void
     * @Author gaoxueyong
     * @Date 5:12 下午 2022/11/8
     * @Param []
     **/
    public void stop() {
        this.liftState.stop();
    }
}
